//
//  WBMTLeftList.m
//  WBMTwaimai
//
//  Created by WangBiao on 16/9/21.
//  Copyright © 2016年 lsrain. All rights reserved.
//

#import "WBMTLeftList.h"

@implementation WBMTLeftList

- (void)setValue:(id)value forKey:(NSString *)key{
    [super setValue:value forKey:key];
    
    NSArray<WBMTRightList *> *arr = (NSArray *)value;
    //将spus取出给rightList赋值
    if ([key isEqualToString:@"spus"]) {
        NSMutableArray *arrM = [NSMutableArray arrayWithCapacity:arr.count];
        [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            WBMTRightList *model = [[WBMTRightList alloc] init];
            [model setValuesForKeysWithDictionary:obj];
            [arrM addObject:model];
        }];
        
        //等同于_spus = arrM.copy;
        [super setValue:arrM forKey:key];
    }
    
}

///重写此方法，防止模型没有对应的key而导致kvc报错
- (void)setValue:(id)value forUndefinedKey:(NSString *)key{}
@end
